package com.tpshion.cloud.auth.domain.dto;

import com.tpshion.cloud.common.support.Constants;
import org.springframework.util.StringUtils;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

@Valid
public class CheckEmailDto {

    @Size(max = 64, message = "用户id长度不能超过64")
    private String userId;

    @NotEmpty(message = "邮箱不能为空")
    @Pattern(regexp = Constants.EMAIL_REGEXP, message = "邮箱不正确")
    private String email;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        return "CheckEmailDto{" +
                "userId='" + userId + '\'' +
                ", email='" + email + '\'' +
                '}';
    }

    public void init(){
        this.userId = StringUtils.isEmpty(this.userId) ? this.userId : this.userId.trim();
        this.email = StringUtils.isEmpty(this.email) ? this.email : this.email.trim();
    }
}
